/*
 * Copyright 2010, 2011 Matt Oliveri
 *
 * This file is part of JConfigGen
 *
 * JConfigGen is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * JConfigGen is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with JConfigGen.  If not, see <http://www.gnu.org/licenses/>.
 */

package atma.jconfiggen;

import java.io.PrintStream;

/** Common abstract superclass of expression types that are essentially Java expression types.
 */
public abstract class CoreExpr extends IdExpr
{
	CoreExpr(Config c,String i) {super(c,i);}

	boolean hasStats() {return id != null;}

	void printStats(PrintStream out,int tabs) throws InvalidConfigException
	{
		if (id == null) return;
		pTabs(out,tabs);
		if (id != none)
		{
			if (oldId) out.print(id);
			else printDecl(out);
			out.print(" = ");
		}
		printCore(out);
		out.println(';');
	}

	void printExpr(PrintStream out)
	{
		if (id == null) printCore(out);
		else out.print(id);
	}

	abstract void printCore(PrintStream out);
}
